﻿

namespace MainConsoleApp
{
    class MainProgram
    {

        static void printSolution(System.Collections.Generic.List<Node> sol)
        {
            if (sol == null) {
                System.Console.WriteLine("No Solution!");
            } else {
                foreach (Node n in sol) {
                    System.Console.WriteLine("State " + n.ToString());
                }
            }
            System.Console.WriteLine();
            System.Console.WriteLine();
            System.Console.WriteLine();
        }


        static void Main(string[] args)
        {
            System.Console.WriteLine("UNINFORMED SEARCH:");

            /** search by BFS */
            {
                BFS bfs = new BFS("../../testFiles/tutorial2-2008-graph_info.txt");
                System.Collections.Generic.List<Node> sol = bfs.genericGraphSearch("1", "15");
                System.Console.WriteLine("Breadth-first search:");
                printSolution(sol);
            }

            /** search by DFS */
            {
                UCS ucs = new UCS("../../testFiles/tutorial2-2008-graph_info.txt");
                System.Collections.Generic.List<Node> sol = ucs.genericGraphSearch("1", "15");
                System.Console.WriteLine("Uniform-cost search:");
                printSolution(sol);
            }


            /** search by DFS */
            {
                DFS dfs = new DFS("../../testFiles/tutorial2-2008-graph_info.txt");
                System.Collections.Generic.List<Node> sol = dfs.genericGraphSearch("1", "15");
                System.Console.WriteLine("Depth-first search:");
                printSolution(sol);
            }

            /** search by DLS (Depth-Limited-Search) */
            {
                DLS dls = new DLS("../../testFiles/tutorial2-2008-graph_info.txt");
                System.Collections.Generic.List<Node> sol = dls.depthLimitedSearch("1", "15", 6);
                System.Console.WriteLine("Depth-limited search:");
                printSolution(sol);
            }


            /** search by IDS (Iterative deepening depth-first search) */
            {
                IDS ids = new IDS("../../testFiles/tutorial2-2008-graph_info.txt");
                System.Collections.Generic.List<Node> sol = ids.iterativeDeepeningSearch("1", "15");
                System.Console.WriteLine("Iterative deepening depth-first search:");
                printSolution(sol);
            }


            System.Console.WriteLine();
            System.Console.WriteLine();
            System.Console.WriteLine();
            
            System.Console.WriteLine("INFORMED SEARCH:");

            /** search by RBFS (Recursive best-fit search) */
            {
                RBFS rbfs = new RBFS("../../testFiles/tutorial2-2008-graph_info.txt");
                Heuristics heuristics = new Heuristics();
                heuristics.readHeuristics("../../testFiles/tutorial2-2008-heuristic-distance.txt");
                heuristics.setGoal("15");

                System.Collections.Generic.List<Node> sol = rbfs.genericGraphSearch("1", "15", heuristics);

                System.Console.WriteLine("Recursive best-fit search:");
                printSolution(sol);           
            }

            /** wait a sec */
            System.Console.ReadLine();
        }
    }
}
